package com.nd.config;

import com.nd.pojo.vo.BaseRespVo;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
//@ResponseBody
//@RestControllerAdvice = @ControllerAdvice + @ResponseBody
public class ExceptionControllerAdvice {

    @ExceptionHandler(HttpMessageNotReadableException.class)
    @ResponseBody
    public BaseRespVo sensitiveException(HttpMessageNotReadableException httpMessageNotReadableException){
        //抛出异常时 可以携带信息
        //处理方法中 可以获得携带的信息
//        String word = httpMessageNotReadableException.getMessage();
        return BaseRespVo.fail("参数填写异常，不要瞎搞，耗子尾滋！");
    }
}

